import { ColumnType } from "antd/es/table"

import { useDigital, useLocale } from "@/hooks"
export interface RootObject {
	itemName: string
	betNumber: number
	placeOrderQuantity: number
	betAmount: number
	validBetAmount: number
	netAmount: number
	titleText?: string
}
const useColumn = () => {
	const { newFormat, formatMessage } = useLocale()
	const { renderFormat, renderColor } = useDigital()
	const dxnItemName: ColumnType<RootObject> = {
		dataIndex: "itemName",
		title: newFormat("title.dxnItemName"),
		align: "center",
		width: 120
	}
	const betNumber: ColumnType<RootObject> = {
		dataIndex: "betNumber",
		title: newFormat("title.betNumber"),
		align: "center",
		width: 120,
		defaultSortOrder: "descend",
		sorter: (a, b) => a.betNumber - b.betNumber
	}
	const placeOrderQuantity: ColumnType<RootObject> = {
		dataIndex: "placeOrderQuantity",
		title: newFormat("title.placeOrderQuantity"),
		align: "center",
		width: 120,
		defaultSortOrder: "descend",
		sorter: (a, b) => a.placeOrderQuantity - b.placeOrderQuantity
	}
	const dxnBetAmount: any = {
		dataIndex: "betAmount",
		title: newFormat("title.betAmount"),
		titleText: formatMessage({ id: "title.betAmount" }),
		align: "center",
		width: 120,
		render: renderFormat
	}
	const dxnValidBetAmount: any = {
		dataIndex: "validBetAmount",
		title: newFormat("label.validBetAmount"),
		titleText: formatMessage({ id: "label.validBetAmount" }),
		align: "center",
		width: 140,
		render: renderFormat
	}
	const netAmount: ColumnType<RootObject> = {
		dataIndex: "netAmount",
		title: newFormat("title.netAmount"),
		align: "center",
		width: 120,
		render: renderColor,
		defaultSortOrder: "descend",
		sorter: (a, b) => a.netAmount - b.netAmount
	}
	return {
		dxnItemName,
		betNumber,
		placeOrderQuantity,
		dxnBetAmount,
		dxnValidBetAmount,
		netAmount
	}
}

export default useColumn
